﻿/**********************************************************************************
 * Project Name :   
 * Remarks      :  
 * Class Name   :  LogModel 
 * Version      :  v1.0.0.0 
 * Author       :  Joey Liang 
 * Description  : 
 * Created Time :  2013/8/14 22:36:26
 * Update Man   :  Joey Liang
 * Update Time  :  2013/8/14 22:36:26
************************************************************************/

using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JoeyLibs.Utility.Log
{
    /// <summary>
    /// 日志记录模型
    /// </summary>
    public abstract class LogModel
    {
        protected LogModel(string message)
        {
            this.message = message;
        }

        private string message;
        /// <summary>
        /// 日志提示信息
        /// </summary>
        public string Message
        {
            get { return message; }
            set { this.message = value; }
        }

        private string reason;
        /// <summary>
        /// 导致问题原因
        /// </summary>
        public string Reason
        {
            get { return reason; }
            set { this.reason = value; }
        }

        private string solution;
        /// <summary>
        /// 解决该问题的提示
        /// </summary>
        public string Solution
        {
            get { return solution; }
            set { solution = value; }
        }

        private ILog log;
        protected abstract ILog Log { get; }
                
        protected virtual ILog GetLogger(string loggerName)
        {
            if (log == null)
            {
                log = LogManager.GetLogger(loggerName);
            }

            return log;
        }

        /// <summary>
        /// 输出日志
        /// </summary>
        public abstract void Output();
    }

    /// <summary>
    /// 日志类型,当大于3时就是程序将无法正常运行的日志
    /// </summary>
    public enum LogType
    {
        /// <summary>
        /// 一般信息
        /// </summary>
        Info = 0,
        /// <summary>
        /// 调试日志
        /// </summary>
        Debug,
        /// <summary>
        /// 性能日志
        /// </summary>
        Performance,
        /// <summary>
        /// 警告日志
        /// </summary>
        Warn,
        /// <summary>
        /// 异常日志
        /// </summary>
        Exception,
        /// <summary>
        /// 错误日志
        /// </summary>
        Error,
        /// <summary>
        /// 毁灭性日志
        /// </summary>
        Fatal
    }
}
